<?php

/**
 * @file z_cefpdf.php
 * @brief Clase para generar un anclas
 * @author DyrTechnologies
 * @version V 1.0
 * @date Tue Dec 18 2007
 *
 *  Part of the CEFIRO dynamic web framework project
 *
 *  Copyright (C) 2007  Dyr technologies http://dyrtech.com.ve
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

if (!defined('CEFIRO')) define("CEFIRO",substr(__FILE__,0,strpos(__FILE__,"cefiro"))."cefiro/widgets/cefiro.php");
require_once(CEFIRO);
require_once(CEF_CHECKBOX);

function getCheckbox(){

  global $smarty;

  $srcDisplay = '
$appleCheckbox = new checkbox(\'appleCheckbox\', \'Apple\');
$appleCheckbox->set_onChange("zajax.call(\'zajax/checkbox/z_checkbox.php\', \'changed\',
                                         new Array(zajax.$(\'appleCheckbox\').checked,
                                                   zajax.$(\'orangeCheckbox\').checked));");
$appleCheckbox->display_checkbox();

$orangeCheckbox = new checkbox(\'orangeCheckbox\', \'Orange\');
$orangeCheckbox->set_onChange("zajax.call(\'zajax/checkbox/z_checkbox.php\', \'changed\',
                                          new Array(zajax.$(\'appleCheckbox\').checked,
                                                    zajax.$(\'orangeCheckbox\').checked));");
$orangeCheckbox->display_checkbox();';

  $tplDisplay = '
<p> {$appleCheckbox} </p>
<p> {$orangeCheckbox} </p>
<div id=\'message\'></div>';

  eval($srcDisplay);

  $smarty->template_dir = dirname(__FILE__).'/';

  addAssign('widgetTitle', 'innerHTML', "<p class='title_blue'>Checkbox</p>");
  addAssign('widgetDisplay', 'innerHTML', $smarty->fetch('z_checkbox.tpl'));

  addAssign('srcTitle', 'innerHTML', "<p class='title_red'>Source</p>");
  addAssign('srcDisplay', 'innerHTML', "<p><pre>".$srcDisplay."</pre></p>");

  $tplDisplay = str_replace('<', '&lt;', $tplDisplay);
  $tplDisplay = str_replace('>', '&gt;', $tplDisplay);

  addAssign('tplTitle', 'innerHTML', "<p class='title_green'>Smarty Template</p>");
  addAssign('tplDisplay', 'innerHTML', "<p><pre>".$tplDisplay."</pre></p>");

	return processResponse();
}

function changed($args){

  if($args[0] == 'true' and $args[1] == 'true')
     addAssign('message', 'innerHTML', 'You like apples and oranges!');

  if($args[0] == 'true' and $args[1] != 'true')
     addAssign('message', 'innerHTML', 'You like apples!');

  if($args[0] != 'true' and $args[1] == 'true')
     addAssign('message', 'innerHTML', 'You like oranges!');

  if($args[0] != 'true' and $args[1] != 'true')
     addAssign('message', 'innerHTML', 'You don\'t like neither apples nor oranges!');

  return processResponse();
}

?>